using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_QLDonHang : System.Web.UI.UserControl
{
    processOrder pOrder;
    protected void Page_Load(object sender, EventArgs e)
    {
        pOrder = new processOrder();

        if (!Page.IsPostBack)
        {
            Load_gvwOrder();
        }
    }

    private void Load_gvwOrder()
    {
        gvwOrder.DataSource = pOrder.listOders();
        gvwOrder.DataBind();
    }

    

    protected void gvwOrder_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvwOrder.PageIndex = e.NewPageIndex;
        Load_gvwOrder();
    }
    protected void gvwOrder_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        string OrderID = gvwOrder.DataKeys[e.NewSelectedIndex].Value.ToString();
        txtOrderID.Text = OrderID.ToString();        
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string OrderID = txtOrderID.Text;
        string OrderStatus = ddlStatus.SelectedValue.ToString();
        if (pOrder.updateOrderinAdmin(OrderID, OrderStatus) > 0)
        {
            Alert.Show("Update Order Status successfull!");
            Load_gvwOrder();
        }
        else
            Alert.Show("Update Order Status unsuccessfull!");
    }
}
